package com.ff.cms.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ff.cms.service.EchartsService;

@Controller
@RequestMapping(value = "/echartsCtl")
public class EchartsController {

	@Autowired
	EchartsService echartsService;
	
	@RequestMapping(value="/toArticleTypeBar")
	public String toArticleTypeBar() {
		
		return "echarts/articleTypeBar";
	}
	
	@ResponseBody
	@RequestMapping(value="/articleTypeBar")
	public Map<String, Object> articleTypeBar() {
		try {
			Map<String, Object> map = new HashMap<String, Object>();
			
			List<String> typeNameList = echartsService.findTypeName();
			List<Integer> typeCountList = echartsService.findTypeCount();
			List<Integer> typeCountList1 = echartsService.findTypeCount1(0);
			List<Integer> typeCountList2 = echartsService.findTypeCount1(1);
			map.put("typeNameList", typeNameList);
			map.put("typeCountList", typeCountList);
			map.put("typeCountList1", typeCountList1);
			map.put("typeCountList2", typeCountList2);
			return map;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}
	
}
